import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sklearn.linear_model import Ridge
from sklearn import model_selection
from sklearn.preprocessing import PolynomialFeatures

data = pd.read_csv('ridge.csv')
data = np.array(data)
# plt.plot(data[:,5])
# plt.show()
X = data[:,:5]
y = data[:,5]

poly = PolynomialFeatures(6)
X = poly.fit_transform(X)

train_set_X,test_set_X,train_set_y,test_set_y =\
    model_selection.train_test_split(X,y,test_size=0.3,random_state=0)

clf = Ridge()
clf.fit(train_set_X,train_set_y)
clf.score(test_set_X,test_set_y)

start = 200
end = 600
y_pre =clf.predict(X)
time = np.arange(start,end)
plt.plot(time,y[start:end],'b',label='real')
plt.plot(time,y_pre[start:end],'r',label='predict')

plt.show()